//
//  ReadWriteUserInfoTool.m
//  FreshMember
//
//  Created by qyc on 2019/4/29.
//  Copyright © 2019年 qyc. All rights reserved.
//

#import "ReadWriteUserInfoTool.h"

#import "HAUserModel.h"

@implementation ReadWriteUserInfoTool
+ (ReadWriteUserInfoTool *)sharedUserInfo {
    static dispatch_once_t pred = 0;
    __strong static ReadWriteUserInfoTool *_sharedUserInfo = nil;
    dispatch_once(&pred, ^{
        _sharedUserInfo = [[ReadWriteUserInfoTool alloc] init];
    });
    return _sharedUserInfo;
}

- (BOOL)isLogged {
    if (self.getUserId != nil) {
        return YES;
    } else {
        return NO;
    }
}

- (BOOL)isInsidEmployee {
    HAUserModel *userModel = [HAUserModel mj_objectWithKeyValues:[UserDefaultHelper getDictForKey:UserInfoKey]];
    if ([userModel.is_staff integerValue] == 1 || [userModel.is_staff integerValue] == 3 ) {
        return YES;
    } else {
        return NO;
    }
}

- (NSString *)getUserId {
    HAUserModel *userModel = [HAUserModel mj_objectWithKeyValues:[UserDefaultHelper getDictForKey:UserInfoKey]];
    if (userModel.Id.length > 0) {
        return userModel.Id;
    }
    return nil;
}

- (NSString *)getUserMobile {
    HAUserModel *userModel = [HAUserModel mj_objectWithKeyValues:[UserDefaultHelper getDictForKey:UserInfoKey]];
    if (userModel.mobile.length > 0) {
        return userModel.mobile;
    }
    return nil;
}

- (NSString *)getCustomer_tel {
    HAUserModel *userModel = [HAUserModel mj_objectWithKeyValues:[UserDefaultHelper getDictForKey:UserInfoKey]];
    if (userModel.customer_tel.length > 0) {
        return userModel.customer_tel;
    }
    return nil;
}

-(NSDictionary *)requestHeaderDictionary {
    //    NSString *client=@"2";
    //    NSString *version=[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];;
    //    NSString *timestamp=@"";
    //    NSString *signType=@"MD5";
    //    NSString *sign=@"";
    //    NSString *uuid = IOS_UIDeviceUUID;
    //    NSString *resolution=[NSString stringWithFormat:@"%.0f*%.0f",kWindowW * 2, kWindowH * 2];
    //    NSString *channelCode=@"appstore";
    //    NSString *osstr = [NSString stringWithFormat:@"iOS%@",CurrentSystemVersion];
    NSDictionary *dict;
    if ([[ReadWriteUserInfoTool sharedUserInfo] isLogged]) {
        dict = @{@"token" : self.getUserId};
    }
    
    return dict;
}
@end
